<template>
  <div id="AddMem">
    <el-dialog
      :title="title"
      :visible="state"
      class="dialog"
      @close="closeDialog"
    >
      <el-form :model="form">
        <el-form-item label="会员姓名" :label-width="formLabelWidth">
          <el-input v-model="form.vip_name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="折扣系数" :label-width="formLabelWidth">
          <el-input v-model="form.vip_discount" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="总消费额" :label-width="formLabelWidth">
          <el-input
            v-model="form.vip_total_consume"
            autocomplete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="会员电话" :label-width="formLabelWidth">
          <el-input v-model="form.vip_phone" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="nosub">取 消</el-button>
        <el-button type="primary" @click="Add">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as api from '../utils/api'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
export default {
  name: 'AddMem',
  props: ['title', 'state', 'form'],
  data() {
    return {
      formLabelWidth: '100px',

    }
  },
  methods: {
    Add() {
      this.$emit('add')
      console.log(this.form)
      this.axios({
        method: 'post',
        url: api.ADDMEM,
        data: this.form
      }).then(data => {
        console.log(data)

        this.form.vip_name = ''
        this.form.vip_discount = ''
        this.form.vip_total_consume = ''
        this.form.vip_phone = ''

        if (data.data.code == 200) {
          this.$emit('shuanxin')
        }
      })
    },
    nosub() {
      this.$emit('add')
    },
    closeDialog() {
      this.$emit('add')
    }
  },

}
</script>

<style scoped>
.el-dialog {
  width: 40% !important;
}
</style>